//Copyright (c) Microsoft Corporation.  All rights reserved.

using System;
using System.Collections.Generic;
using System.Text;

namespace Eas.WebCrawler.PlugIns.RequestComparers
{
    /// <summary>A base class for <see cref="BaseComparer"/>s which contains an inner instance of <see cref="BaseComparer"/> to which you can delegate if necessary.</summary>
    public class DecoratingComparer : BaseComparer
    {
        private BaseComparer _InnerComparer;

        /// <summary>The inner <see cref="BaseComparer"/>.</summary>
        public BaseComparer InnerComparer
        {
            get { return _InnerComparer; }
        }

        /// <summary>Constructs a <see cref="DecoratingComparer"/> from an inner <see cref="BaseComparer"/>.</summary>
        /// <param name="innerComparer">The inner <see cref="BaseComparer"/> to which dervied classes can delegate.</param>
        public DecoratingComparer(BaseComparer innerComparer)
        {
            _InnerComparer = innerComparer;
        }

        /// <summary>Compares two Uris for priority.  This can (and probably should) be overriden by derived classes.</summary>
        /// <param name="leftRequest">The left <see cref="Eas.WebCrawler.Interfaces.Request"/> to compare.</param>
        /// <param name="rightRequest">The right <see cref="Eas.WebCrawler.Interfaces.Request"/> to compare.</param>
        /// <returns>A <see cref="CompareResult"/> declaring if the left or right <see cref="Eas.WebCrawler.Interfaces.Request"/> is higher priority.</returns>
        /// <remarks>This implementation just calls into the inner <see cref="BaseComparer"/> so derived classes will likely do their own thing here unless that is the desired behavior.</remarks>
        public override CompareResult CompareUris(Eas.WebCrawler.Interfaces.Request leftRequest, Eas.WebCrawler.Interfaces.Request rightRequest)
        {
            return _InnerComparer.CompareUris(leftRequest, rightRequest);    
        }
    }
}
